import React, {useEffect, useState} from 'react'
import {
  Form,
  Button,
  Input,
  Modal,
  DatePicker,
  Select,
  Row,
  Col,
  TreeSelect,
  Card,
  Upload,
  message,
  Cascader
} from 'antd'
import {
  probationDayList,
  socialTraineeStateArray,
  genderList,
  nationList,
  maritalList,
  isRemoteSocialSecurityList
} from '@/utils/constant'
import {getJobByOrgId, getEmployeeSalaryBpmById, getEmployeeRecruitmentByOid} from '../../service'
import {findItemByTree} from '@/utils/functions'
import {UploadOutlined} from '@ant-design/icons';
import moment from 'moment'
import {connect, history} from 'umi'
import {getUploadUrl} from "@/utils/upload";

const FormItem = Form.Item;
const {Option} = Select;
const {TextArea} = Input;
const formLayout = {
  labelCol: {span: 7},
};

const colStyle = {
  xl: 8,
  lg: 8,
  md: 8,
  sm: 8,
  xs: 8,
};

let fileUploadUrlObj = {
  evaluation: [],
  backReport: [],
  resume: [],
  invitationLetter: [],
  measure: [],
  prove: [],
  otherAtt: []
};

const CreateForm = (props) => {

  const {onSubmit, onCancel, currentUser, current, global = {}, loading = false} = props;
  const {options = {}} = global;
  const {orgTree = [], nativePlace = [], jobLevel = []} = options;
  const [fileName, setFileName] = useState(null);
  const [isShow, setIsShow] = useState(null);
  const [evaluation, setEvaluation] = useState([]);
  const [backReport, setBackReport] = useState([]);
  const [resume, setResume] = useState([]);
  const [invitationLetter, setInvitationLetter] = useState([]);
  const [measure, setMeasure] = useState([]);
  const [prove, setProve] = useState([]);
  const [otherAtt, setOtherAtt] = useState([]);
  const [type,setType] = useState(null);

  const [form] = Form.useForm();
  const [formVals, setFormVals] = useState({
    socialTrainee: '0',
    principal: currentUser.name,
    id: props.values.id,
  });

  const getFileProps = (urlsKey) => ({
    name: 'file',
    multiple: false,
    action: getUploadUrl(),
    data: {name: fileName},
    beforeUpload(file) {
      setFileName(file.name)
    },
    fileList: resultFile(null, urlsKey),
    onChange(info) {
      const {status} = info.file;
      if (status === 'done') {
        if (info.file.response.error) {
          message.success(`${info.file.response.error} 。`);
        } else {
          let urls = fileUploadUrlObj[urlsKey];
          urls.push(info.file.response);
          fileUploadUrlObj[urlsKey] = urls;
          message.success(`${info.file.name} 文件上传成功。`);
        }
      } else if (status === 'error') {
        message.error(`${info.file.name} 文件上传失败。`);
      }
      let t = info.fileList.filter(item => item.status);
      resultFile([...t], urlsKey);
    },
    onRemove(info) {
      let index = fileUploadUrlObj[urlsKey].indexOf(info.url);
      if (index > -1) {
        fileUploadUrlObj[urlsKey].splice(index, 1);
      }
      let tempData = resultFile(null, urlsKey);
      let tempIndex = tempData.indexOf(info.url);
      if (tempIndex > -1) {
        tempData.splice(tempIndex, 1);
      }
    }
  });

  const resultFile = (data, type) => {
    if (data) {
      switch (type) {
        case 'evaluation': {setEvaluation(data);break;}
        case 'backReport': {setBackReport(data);break;}
        case 'resume': {setResume(data);break;}
        case 'invitationLetter': {setInvitationLetter(data);break;}
        case 'measure': {setMeasure(data);break;}
        case 'prove': {setProve(data);break;}
        case 'otherAtt': {setOtherAtt(data);break;}
      }
    } else {
      switch (type) {
        case 'evaluation': {return evaluation;}
        case 'backReport': {return backReport;}
        case 'resume': {return resume;}
        case 'invitationLetter': {return invitationLetter;}
        case 'measure': {return measure;}
        case 'prove': {return prove;}
        case 'otherAtt': {return otherAtt;}
      }
    }
  };

  const [unitTree, setUnitTree] = useState([]);
  const [jobList, setJobList] = useState([]);
  const [oid, setOid] = useState();
  const [isReinstate, setIsReinstate] = useState();
  const [tempData, setTempData] = useState({});

  useEffect(() => {
    if (current) {
      form.setFieldsValue({
        ...current, hiredate: current.hiredate ? moment(current.hiredate) : undefined,
        beginworkdate: current.beginworkdate ? moment(current.beginworkdate) : undefined,
        birthday: current.birthday ? moment(current.birthday) : undefined, oldSalary: null
      });
      setOid(current.oid);
      setIsReinstate(current.isReinstate);
      const item = findItemByTree(orgTree, parseInt(current.orgId));
      setUnitTree(item ? item.children : []);

      //把保存的数据set到表单中
      getEmployeeRecruitmentByOid(current.oid).then(res => {
        let temp = [];
        if(res.isRemoteSocialSecurity !== 0){
          if (res.socialSecurityProvince) {
            temp.push(parseInt(res.socialSecurityProvince))
          }
          if (res.socialSecurityCity) {
            temp.push(parseInt(res.socialSecurityCity))
          }
        }else{
          setIsShow(0);
        }
        form.setFieldsValue({
          beforeSalary: res.beforeSalary,
          beforeBasicSalary: res.beforeBasicSalary,
          beforePerformanceSalary: res.beforePerformanceSalary,
          proMonthSalary: res.proMonthSalary,
          proBasicSalary: res.proBasicSalary,
          proPerformanceSalary: res.proPerformanceSalary,
          monthlySalary: res.monthlySalary,
          basicSalary: res.basicSalary,
          performance: res.performance,
          afterSalary: res.afterSalary,
          afterBasicSalary: res.afterBasicSalary,
          afterPerformanceSalary: res.afterPerformanceSalary,
          oldSalary: res.oldSalary,
          socialSecurityCity: temp,
          evaluation: res.evaluation,
          backReport: res.backreport,
          resume: res.resume,
          invitationLetter: res.invitationletter,
          measure: res.measure,
          prove: res.prove,
          otherAtt: res.otheratt,
          empRemark:res.empRemark
        });
        fileUploadUrlObj.evaluation = checkNull(res.evaluation);
        fileUploadUrlObj.backReport = checkNull(res.backreport);
        fileUploadUrlObj.resume = checkNull(res.resume);
        fileUploadUrlObj.invitationLetter = checkNull(res.invitationletter);
        fileUploadUrlObj.measure = checkNull(res.measure);
        fileUploadUrlObj.prove = checkNull(res.prove);
        fileUploadUrlObj.otherAtt = checkNull(res.otheratt);
        Object.keys(fileUploadUrlObj)?.map(item =>{
          if(fileUploadUrlObj[item][0]){
            vrayFile(fileUploadUrlObj[item],item);
          }
        })
      });

      if (current.isReinstate !== 0) {
        //非新员工
        getEmployeeSalaryBpmById(current.oid).then((res) => {
          setTempData({
            oldCompanyId: res.oldCompanyId,
            oldDepartmentId: res.oldDepartmentId,
            oldJobLevelId: res.oldJobLevelId
          });
          form.setFieldsValue({
            oldOrgName: res.oldCompany,
            oldUnitname: res.oldDepartment,
            oldJobName: res.oldJobLevelId && res.oldJobLevelId.toString()
          })
        })
      }
      form.setFieldsValue({
        orgId: current.orgId ? parseInt(current.orgId) : undefined,
        unitId: current.unitId ? parseInt(current.unitId) : undefined
      });
      current.unitId && getJobByOrgId(current.unitId).then((res) => {
        setJobList(res)
      })
    }
  }, [current]);

  const checkNull = (value) =>{
    let data = [];
    if(value){
      data.push(value);
    }
    return data;
  };

  const vrayFile = (list,key) =>{
    let data = [];
    list?.map((item,index) => {
      data.push({
        uid: index,
        name: item.split('----')[1],
        status: 'done',
        url: item,
      })
    });
    resultFile(data,key);
  };

  const onFormCancel = () => {
    form.resetFields();
    onCancel();
    setType(null);
    fileUploadUrlObj = {
      evaluation: [],
      backReport: [],
      resume: [],
      invitationLetter: [],
      measure: [],
      prove: [],
      otherAtt: []
    };
  }

  const onChangeOrgId = (e) => {
    const item = findItemByTree(orgTree, e);
    setUnitTree(item ? item.children : [])
  }

  const handleSubmit = async (type) => {
    setType(type);
    const fieldsValue = await form.validateFields();
    if (fileUploadUrlObj.evaluation.length < 1 || fileUploadUrlObj.resume.length < 1) {
      message.error('存在无效文件，请重新上传');
      return;
    }
    let {socialSecurityCity, ...data} = fieldsValue;
    data.socialSecurityProvince = (socialSecurityCity && socialSecurityCity.length > 0) ? socialSecurityCity[0] : null;
    if (socialSecurityCity && socialSecurityCity.length > 1) {
      data.socialSecurityCity = socialSecurityCity[1];
    } else {
      data.socialSecurityCity = (socialSecurityCity && socialSecurityCity.length > 0) ? socialSecurityCity[0] : null;
    }
    form.resetFields();
    onSubmit({...data, oid: oid, ...fileUploadUrlObj, isReinstate: isReinstate, ...tempData, type: type});
    fileUploadUrlObj = {
      evaluation: [],
      backReport: [],
      resume: [],
      invitationLetter: [],
      measure: [],
      prove: [],
      otherAtt: []
    };
  };

  const onChangeUnitId = (e) => {
    getJobByOrgId(e).then((res) => {
      setJobList(res)
    })
  };

  const filterOption = (input, option) => {
    return option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
  };

  const setNativePlaceLabel = (label) => {
    if (typeof label !== 'string') {
      return label.join('');
    } else {
      return [label].join('');
    }
  };

  const handleOffSiteChange = (value) => {
    if (value === 0) {
      form.setFieldsValue({socialSecurityCity: []})
    }
    setIsShow(value);
  };

  const renderContent = () => {
    return (
      <>
        <Row gutter={24}>
          <Col {...colStyle}>
            <FormItem name="name" label="姓名">
              <Input disabled={true}/>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <FormItem label="性别" name="gender">
              <Select placeholder="请选择" disabled={true}>
                {genderList.map((item, index) => {
                  return (
                    <Option value={`${item.value}`} key={item.value}>
                      {item.label}
                    </Option>
                  )
                })}
              </Select>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <FormItem label={'民族'} name="nationality">
              <Select placeholder="请选择" disabled={true} showSearch filterOption={filterOption}>
                {nationList.map((item, index) => {
                  return (
                    <Option value={`${item.value}`} key={item.value}>
                      {item.label}
                    </Option>
                  )
                })}
              </Select>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <FormItem label={'婚姻状况'} name="marital">
              <Select placeholder="请选择" disabled={true}>
                {maritalList.map((item, index) => {
                  return (
                    <Option value={`${item.value}`} key={item.value}>
                      {item.label}
                    </Option>
                  )
                })}
              </Select>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <FormItem name="workAddress" label="工作地点">
              <Input disabled={true}/>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <FormItem label={'参加工作时间'} name="beginworkdate">
              <DatePicker disabled={true} placeholder="请选择日期" style={{width: '100%'}}/>
            </FormItem>
          </Col>

          <Col span={isReinstate === 0 ? 0 : 8}>
            <FormItem name="oldOrgName" label={'原公司'}>
              <TreeSelect disabled={true}/>
            </FormItem>
          </Col>
          <Col span={isReinstate === 0 ? 0 : 8}>
            <FormItem name="oldUnitname" label={'原部门'}>
              <TreeSelect disabled={true}/>
            </FormItem>
          </Col>
          <Col span={isReinstate === 0 ? 0 : 8}>
            <Form.Item name="oldJobName" label={'原职级'}>
              <Select placeholder="请选择" disabled={true} showSearch filterOption={filterOption}>
                {
                  jobLevel.map((item, index) => {
                    return (
                      <Option value={`${item.id}`} key={item.name}>
                        {item.name}
                      </Option>
                    )
                  })
                }
              </Select>
            </Form.Item>
          </Col>

          <Col {...colStyle}>
            <FormItem name="orgId" label={isReinstate === 0 ? '录用公司' : '复职公司'}>
              <TreeSelect disabled={true} treeData={orgTree} onChange={onChangeOrgId}/>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <FormItem name="unitId" label={isReinstate === 0 ? '录用部门' : '复职部门'}>
              <TreeSelect disabled={true} treeData={unitTree} onChange={onChangeUnitId}/>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <Form.Item name="jobLevelId" label={isReinstate === 0 ? '录用职级' : '复职职级'}>
              <Select placeholder="请选择" disabled={true} showSearch filterOption={filterOption}>
                {
                  jobLevel.map((item, index) => {
                    return (
                      <Option value={item.id} key={item.name}>
                        {item.name}
                      </Option>
                    )
                  })
                }
              </Select>
            </Form.Item>
          </Col>
          <Col {...colStyle}>
            <FormItem name="jobId" label="录用岗位">
              <Select placeholder="请选择" disabled={true} showSearch filterOption={filterOption}>
                {jobList.map((item, index) => {
                  return (
                    <Option value={`${item.coidassignedjob}`} key={item.coidassignedjob}>
                      {item.cname}
                    </Option>
                  )
                })}
              </Select>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <FormItem name="socialTrainee" label="招聘类型">
              <Select placeholder="请选择" disabled={true}>
                {socialTraineeStateArray.map((item, index) => {
                  return (
                    <Option value={`${index}`} key={index}>
                      {item}
                    </Option>
                  )
                })}
              </Select>
            </FormItem>
          </Col>
          <Col {...colStyle}>
            <FormItem name="hiredate" label="入职日期">
              <DatePicker className='widthStyle' disabled={true}/>
            </FormItem>
          </Col>
          <Col span={isReinstate === 1 ? 0 : 8}>
            <FormItem name="probationday" label="试用期">
              <Select placeholder="请选择" disabled={true} showSearch filterOption={filterOption}>
                {probationDayList.map((item, index) => {
                  return (
                    <Option value={item.value} key={item.value}>
                      {item.label}
                    </Option>
                  )
                })}
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Card title="薪酬社保信息" className='salary' bordered={false}>
          <Row gutter={24}>
            <Col span={isReinstate === 0 ? 0 : 8}>
              <FormItem name="beforeSalary" label="原月薪"
                        rules={isReinstate === 0 ? '' : [{required: true, message: '原月薪不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col span={isReinstate === 0 ? 0 : 8}>
              <FormItem name="beforeBasicSalary" label="原基本工资"
                        rules={isReinstate === 0 ? '' : [{required: true, message: '原基本工资不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col span={isReinstate === 0 ? 0 : 8}>
              <FormItem name="beforePerformanceSalary" label="原模块工资"
                        rules={isReinstate === 0 ? '' : [{required: true, message: '原模块工资不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>

            <Col span={isReinstate === 1 ? 0 : 8}>
              <FormItem name="proMonthSalary" label="试用期月薪"
                        rules={isReinstate === 1 ? '' : [{required: true, message: '试用期月薪不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col span={isReinstate === 1 ? 0 : 8}>
              <FormItem name="proBasicSalary" label="试用期基本工资"
                        rules={isReinstate === 1 ? '' : [{required: true, message: '试用期基本工资不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col span={isReinstate === 1 ? 0 : 8}>
              <FormItem name="proPerformanceSalary" label="试用期模块工资"
                        rules={isReinstate === 1 ? '' : [{required: true, message: '试用期模块工资不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>

            <Col span={isReinstate === 1 ? 0 : 8}>
              <FormItem name="monthlySalary" label="转正月薪"
                        rules={isReinstate === 1 ? '' : [{required: true, message: '转正月薪不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col span={isReinstate === 1 ? 0 : 8}>
              <FormItem name="basicSalary" label="转正基本工资"
                        rules={isReinstate === 1 ? '' : [{required: true, message: '转正基本工资不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col span={isReinstate === 1 ? 0 : 8}>
              <FormItem name="performance" label="转正模块工资"
                        rules={isReinstate === 1 ? '' : [{required: true, message: '转正模块工资不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>

            <Col span={isReinstate === 1 ? 8 : 0}>
              <FormItem name="afterSalary" label="复职月薪"
                        rules={isReinstate === 1 ? [{required: true, message: '复职月薪不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })] : ''}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col span={isReinstate === 1 ? 8 : 0}>
              <FormItem name="afterBasicSalary" label="复职基本工资"
                        rules={isReinstate === 1 ? [{required: true, message: '复职基本工资不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })] : ''}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col span={isReinstate === 1 ? 8 : 0}>
              <FormItem name="afterPerformanceSalary" label="复职模块工资"
                        rules={isReinstate === 1 ? [{required: true, message: '复职模块工资不能为空'}, ({
                          validator(rule, value) {
                            let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                            if (pattern.test(value)) {
                              return Promise.resolve();
                            }
                            return Promise.reject('请输入数字类型的正确金额');
                          },
                        })] : ''}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="oldSalary" label="原单位月薪" rules={[{required: true, message: '原单位月薪不能为空'}, ({
                validator(rule, value) {
                  let pattern = /(^[1-9]([0-9]*)$|^[0-9]$)/;
                  if (pattern.test(value)) {
                    return Promise.resolve();
                  }
                  return Promise.reject('请输入数字类型的正确金额');
                },
              })]}>
                <Input suffix="元"/>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="isRemoteSocialSecurity" labelCol={{span: 8}} label="是否社保异地代缴"
                        rules={[{required: true, message: '是否社保异地代缴不能为空'}]}>
                <Select placeholder="请选择" onChange={(e) => handleOffSiteChange(e)}>
                  {isRemoteSocialSecurityList.map((item, index) => {
                    return (
                      <Option value={item.value} key={item.value}>
                        {item.label}
                      </Option>
                    )
                  })}
                </Select>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="socialSecurityCity" label="代缴省市"
                        rules={isShow === 1 ? [{required: true, message: '代缴省市不能为空'}] : ''}>
                <Cascader disabled={isShow === 0} fieldNames={{label: 'title', value: 'value', children: 'children'}}
                          displayRender={(label) => setNativePlaceLabel(label)} placeholder="请输入"
                          options={nativePlace}/>
              </FormItem>
            </Col>
          </Row>
        </Card>
        <Card title="支撑材料" className='salary' bordered={false} extra='附件上传大小不能超过10M'>
          <Row>
            <Col {...colStyle}>
              <FormItem name="evaluation" label="面试评价表" rules={[{required: true, message: '面试评价表不能为空'}]}>
                <Upload {...getFileProps('evaluation')} >
                  <Button>
                    <UploadOutlined/> 点击上传附件
                  </Button>
                </Upload>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="backReport" label="背调报告" extra="录用M3及P6以上此项必须提供">
                <Upload {...getFileProps('backReport')} >
                  <Button>
                    <UploadOutlined/> 点击上传附件
                  </Button>
                </Upload>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="resume" label="简历原件" rules={[{required: true, message: '简历原件不能为空'}]}>
                <Upload {...getFileProps('resume')} >
                  <Button>
                    <UploadOutlined/> 点击上传附件
                  </Button>
                </Upload>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="invitationLetter" label="录用邀约函" extra="录用M1及P4以上此项必须提供">
                <Upload {...getFileProps('invitationLetter')} >
                  <Button>
                    <UploadOutlined/> 点击上传附件
                  </Button>
                </Upload>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="measure" label="岗位薪资测算表" extra="录用人员地产体系M7以上，营销体系M2以上此项必须提供">
                <Upload {...getFileProps('measure')} >
                  <Button>
                    <UploadOutlined/> 点击上传附件
                  </Button>
                </Upload>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="prove" label="银行流水/薪资证明" extra="录用M1及P4以上此项必须提供">
                <Upload {...getFileProps('prove')} >
                  <Button>
                    <UploadOutlined/> 点击上传附件
                  </Button>
                </Upload>
              </FormItem>
            </Col>
            <Col {...colStyle}>
              <FormItem name="otherAtt" label="其他附件">
                <Upload {...getFileProps('otherAtt')} >
                  <Button>
                    <UploadOutlined/> 点击上传附件
                  </Button>
                </Upload>
              </FormItem>
            </Col>
          </Row>
          <Row gutter={24}>
            <Col className='widthStyle hire-style'>
              <FormItem name="empRemark" label="备注">
                <TextArea rows={8}/>
              </FormItem>
            </Col>
          </Row>
        </Card>
      </>
    )
  }

  const renderFooter = () => {
    return (
      <>
        <Button onClick={() => onFormCancel()}>取消</Button>
        <Button onClick={() => handleSubmit("save")} loading={loading && type === 'save'}>保存</Button>
        <Button type="primary" onClick={() => handleSubmit("launch")} loading={loading && type === 'launch'}>发起录用流程</Button>
      </>
    )
  };

  return (
    <Modal
      width={1280}
      destroyOnClose
      title="发起录用"
      visible={!!current}
      footer={renderFooter()}
      onOk={handleSubmit}
      onCancel={() => onFormCancel()}
      okText="确认"
      cancelText="取消"
    >
      <Form
        {...formLayout}
        form={form}
        initialValues={{...formVals}}
        style={{paddingTop: '24px'}}
      >
        {renderContent()}
      </Form>
    </Modal>
  )
}

export default connect(({user, global}) => ({
  currentUser: user.currentUser,
  global
}))(CreateForm)
